package com.pan.note.controller;


import com.pan.note.service.UserService;
import com.pan.note.vo.UserDisplayVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

/**
 * 用户增删改查相关controller
 */
@Controller@RequestMapping(value = "/note")
public class UserController {

    @Autowired
    private UserService userService;

    /**
     * 根据用户账号查找用户好友
     * @return 用户好友列表
     */
    @ResponseBody
    @RequestMapping("/user/list")
    public ResponseEntity<List<UserDisplayVo>> getUser(String accountId){
        List<UserDisplayVo> userDisplayVos = userService.dispalyUserList(accountId);
        Map<String, Integer> notCheckMsg = userService.findNotCheckMsg(accountId, userDisplayVos);
        return ResponseEntity.ok(userDisplayVos);
    }

    /**
     * 根据用户账号查找用户好友
     * @return 用户好友列表
     */
    @RequestMapping("/list/game")
    public String getGameUser(String accountId, Model model){
        List<UserDisplayVo> userDisplayVos = userService.dispalyUserList(accountId);
        model.addAttribute("friendLists",userDisplayVos);
        return "common::gameFriendList";
    }

    @ResponseBody
    @RequestMapping("/note/user/findMe")
    public UserDisplayVo getMe(String accountId){
        return userService.findMe(accountId);
    }
}
